#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         __init__.py
#
# Copyright:    Copyright (c) 2005, Faulkner Technologies
#
# Author:       Brian Oliver
#
# Description:  Initialises Sub-Package Accessories
#####################################################################

#####################################################################
## Knowledge Engine Library Imports
# (none - done automatically. see below)

#####################################################################
## Zope Library Imports
from Products.KnowledgeEngine.Common import getProductDirectory

#####################################################################
## Python Library Imports
import os

#####################################################################
## Python Logging Configuration
import logging
log = logging.getLogger("KnowledgeEngine.Startup")
    
#####################################################################    
## Import the KnowledgeEngine Accessories
##
## Each KnowledgeEngine Accessory resides in single *Accessory.py file
## (named after the accessory) within the Accessories folder
## in the KnowledgeEngine Zope Product
##
## By individually importing each accessory, they have a chance of
## performing their own initialisation, including appropriately
## registering themselves as part of the KnowledgeEngine product.

# The path to the KnowledgeEngine Accessories Package
ACCESSORIES_PATH = getProductDirectory() + os.sep + "Accessories"

# Dynamically import each of the defined Accessories in the ACCESSORIES_PATH
for accessory in [file for file in os.listdir(ACCESSORIES_PATH) if os.path.isdir(ACCESSORIES_PATH + os.sep + file)]:
    
    # Import the current accessory (if it doesn't contain a .)
    if accessory.find(".") < 0:
        log.info("Registering Accessory: " + accessory)
        
        exec "from Products.KnowledgeEngine.Accessories." + accessory + " import *"

#####################################################################    
